package org.qq.clientthread;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.Socket;

import javax.swing.JOptionPane;

/**
 * 
 * project_name:QQ
 * package_name:org.qq.clientthread
 * file_name:ClientModifyThread.java
 * @author Link
 * create_date:2015年8月31日下午10:55:54
 * modified_date:
 * description: 修改用户信息线程
 *
 */
public class ClientModifyThread extends Thread{
	private Socket s;					//套接字
	private BufferedReader br = null;	//输入流
	private PrintStream ps = null;		//输出流
	String str = null;					//接收客户返回信息字符串
	
	public ClientModifyThread() {
		super();
	}

	public ClientModifyThread(Socket s) {
		super();
		this.s = s;
	}

	@Override
	public void run() {
		while(true){
			try {
				br = new BufferedReader(new InputStreamReader(s.getInputStream()));
				str = br.readLine();
			} catch (IOException e) {
				return;
			}
			if(str.endsWith("true----modify")){
				JOptionPane.showMessageDialog(null, "修改成功!\n请牢记修改信息!","提示窗口",JOptionPane.YES_OPTION);
			}else if(str.endsWith("false----modify")){
				JOptionPane.showMessageDialog(null, "用户名错误,请重新输入!","错误提示",JOptionPane.ERROR_MESSAGE);
			}
		}
	}
	public synchronized void sendMessageToServer(String modifystr){
		try {
			ps = new PrintStream(s.getOutputStream());
		} catch (IOException e) {
			e.printStackTrace();
		}
		ps.println(modifystr);
	}
}
